Custom image driver - converting the image colorspace

I never got round to testing this, but maybe you can do the same as described here:

preserving the existing color space rather than applying another one.