I had the same problem don't worry. Occasionally still do but its far rarer. All I can say is make sure you are as hard as humanly possible, then be swift! Get the condom on and get inside her as quick as possible, before your dick has time to get soft.
If it does go soft, you could always try and leave the condom on (would go loose I know but should still work) and try and get hard again from scratch with it on. Hope that helps in some way.