You can put a screen on top of your barrel that lets water in but not insects, or you can add a few drops of soap, or oil like neem which will help suffocate the bastards.
Personally I use a few barrels worth of water on most hot days so there is very little time for insects to reproduce. Just try to use up the whole barrel before it gets re-filled
On a side note, did you know that saving rain-water is often illegal depending on where you live. Never enforced but there is still a law. It was probably introduced so people or companies don't set-up huge water collectors limiting the amount of water that replenishes the aquafirs
Colorado, Utah, and Washington State are 3 places that its illegal in the US
Strange too how you are actually required to practice rainwater harvesting in Santa Fe County, Bernalillo County and the city of Albuquerque in New Mexico.