Three Israeli hostages have been freed from Gaza under a ceasefire agreement between Israel and Hamas after a dispute this week threatened to derail the deal.