You can see a dark circle for the testes on the lateral side of the pupae in males. Look at the bottom right hand corner of this "Learning to Fly" poster to tell the difference between male and female.
I usually sex them at "black pupal" stage (just before eclosion). I sex them through their sex combs: only males have them on the legs. Don't select them in earlier pupal stages or you will not be able to distinguish them.
The really easy way to do it is to sex wandering L3 larvae by identifying the enlarged male gonad. These are ~2/3 down the length of the larvae moving from anterior, presenting as less opaque bilaterally symmetrical 'holes' (also referred to as the 'donut') embedded laterally in the fat body. If these are present, it's a male. If they aren't apparent, it's a female.
Separate these out, place them on Whatman paper with moistened tissues underneath in petri dishes and let them develop at 25ºC (so you can stage them). In the first instance you can allow them to develop to adults (and score for your efficiency in sexing the larvae). One you're comfortable what you are a 100% accurate then let the sexed/selected larvae develop into whatever stage pupae you are interested in.