Jean-Philippe Mateta scored twice as France came from behind to beat Egypt 3-1 after extra-time and set up an Olympic men's football final against Spain.