Changed CGColorSpaceCreateDeviceRGB to CGImageGetColorSpace(self.CGImage).

put some code in saving images into an autorelease pool.