European creditors and Greece have come to terms that may help the country avert a financial collapse and keep it in the eurozone.