Cuba and the US are set to restore diplomatic relations and open embassies for the first time in more than 50 years.