The operand size in some write is probably bigger than expected, which is probably causing the red channel to be over-written. Try disabling / trapping some memory writes to track down the problem.
Try with a new version of emscripten, when it comes out.
This is something specific to the emscript port; it works fine on native.
Example : http://i.imgur.com/Oet69lD.png
Thoughts: