title: glReadPixels -> NSData -> save image
body: <p>I create NSBitmapImageRep witch I fill with glReadPixels information. It looks like this:</p>
  
  <pre><code>    NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:width pixelsHigh:height bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:3 * width bitsPerPixel:0];
      glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, [imageRep bitmapData]);
  </code></pre>
  
  <p>and later turn it to NSData and write to file. But I get flipped upside down image. How can I fix it?</p>