Spain offers to take in a ship stranded in the Mediterranean with 629 migrants aboard after Italy and Malta refused to let the vessel dock in their ports.