try this
NSImageRep* theImageRep = [inputImage bestRepresentationForDevice:
[NSDictionary dictionaryWithObject: NSDeviceRGBColorSpace
forKey: NSDeviceColorSpaceName]];
NSString* theColorSpace = [theImageRep colorSpaceName];
if ([theColorSpace isEqualToString: NSDeviceCMYKColorSpace])
{
NSBitmapImageRep* theRGBImageRep = [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL
pixelsWide: [theImageRep pixelsWide]
pixelsHigh: [theImageRep pixelsHigh]
bitsPerSample: 8
samplesPerPixel: 4
hasAlpha: YES
isPlanar: NO
colorSpaceName: NSDeviceRGBColorSpace
bytesPerRow: 0
bitsPerPixel: 0] autorelease];
NSGraphicsContext* theContext = [NSGraphicsContext
graphicsContextWithBitmapImageRep: theRGBImageRep];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: theContext];
NSRect theBoundsRect = NSMakeRect(0.0, 0.0, [theRGBImageRep pixelsWide],
[theRGBImageRep pixelsHigh]);
[[NSColor clearColor] set];
NSRectFill(theBoundsRect);
[theImageRep drawInRect: theBoundsRect];
[NSGraphicsContext restoreGraphicsState];
ASSIGNOBJECT(rgbImage, [[[NSImage alloc] initWithSize: [theImageRepsize]] autorelease]);
[rgbImage addRepresentation: theRGBImageRep];
}
else
{
ASSIGNOBJECT(rgbImage, inputImage);
}