Make sure you're reading and writing 32-bit data. GL_RGB will only give you 24 bits -- try GL_RGBA with glReadPixels() to get the alpha values. Then you'll have to play around with pixel formats to determine if you need to use ABGR or BGRA for writing your image.