When I was younger i asked my eye doc and he said something about it being the result of the light-sensitive rods and cones in your retina becoming momentarily overwhelmed by an immediate influx of light, causing "spots".
I've also heard thought it can be the result of burns in the retna.