Basically it's your eyes/brain overcompensating when you switch away from the colours you've been staring at. For example, the sky is yellow, so when you stare at it your brain begins to overcompensate by adding the optical opposite of yellow, which is blue. When you switch to the greyscale image it take a few seconds for the blue-adding process to turn off.
You can achieve a similar effect by staying in a darkened room for 30 seconds, and then stepping out into bright sunlight. Your eyes overcompensate for the amount of light present and everything looks really bright for a while. The same happens in the other direction, which is why it takes some time to see in the dark well.
These real-world situations involve white light which comprises all the different wavelengths/colours. But your brain can process each wavelength individually and compensate for colours as well as light intensity - like when you put on a pair of yellow-tinted sunglasses, wear them for a while, forget you have them on, then take them off and everything looks blue. That's what's happening in this optical illusion.