Roger Federer has reached the semi-finals of the Miami Open after a hard-fought 6-2 3-6 7-6 victory over Tomas Berdych.