The real cause of the problem for the texture corruption was when using textures with no alpha.
The function bitsPerPixelForFormat returns the wrong number for RGB_888.