From N-player differential games to the master equation in mean field games