Can't save images when cloned/copied

Hi, I got a strange problem. Maybe I make a mistake, but can’t find solution for it.
Problem is like this:

if I do that code:

  
   
ofImage img;  
img.loadImage("someImage.jpg");  
img.saveImage("someName.jpg");  
  

works everything fine, but when I do:

  
   
ofImage img;  
ofImage img2;  
img.loadImage("someImage.jpg");  
img2 = img; // I tried with clone() to  
  
img2.draw(0,0);  // draws ok  
img2.saveImage("someOtherName.jpg"); //doesn't save   
  

“img2” can draw image that I made copy from “img” , but I can’t use “img2” to save it.
Program is far more complicated, but problem turns out that simple. I checked several times everything and tried serveral things. I used setPixels(), update() etc. I can only draw, but no save.

if you do this once in setup, does it work?

if you do it in update() or draw(), you might have a problem – because when the app closes, it might be in the middle of saving the results. then when you try to open the results, it will be corrupted.

really, that’s possible? That sounds like a big bug to me. Why would oF close down before all running operations are completed?

I didn’t checked it in setup() cause I can’t do what I need to do i setup().

After a night without sleep I managed to make it working. I’m using directly FreeImage code and it works.
Maybe someone will need it so I give it:

  
  
  
FIBITMAP * getBmpFromPixels(ofPixels &pix){  
  
  
        FIBITMAP * bmp = NULL;  
	int w						= pix.getWidth();  
	int h						= pix.getHeight();  
	unsigned char * pixels		= pix.getPixels();  
	int bpp						= pix.getBitsPerPixel();  
	int bytesPerPixel			= pix.getBitsPerPixel() / 8;  
  
  
    // part for little endian  
    unsigned char temp;  
    int pos;  
    for (int i = 0; i < w*h; i++){  
					pos = i * 3;  
					temp = pixels[pos  ];  
					pixels[pos  ] = pixels[pos+2];  
					pixels[pos+2] = temp;  
    }//end of part  
  
	bmp	= FreeImage_ConvertFromRawBits(pixels, w,h, w*3,24,0,0,0, true);  
	  
	return bmp;  
}  
  
    string fname = "saveexamaple"+ofToString(count)+".jpg";  
    FREE_IMAGE_FORMAT fif = FIF_JPEG;  
    FIBITMAP * bmp	= getBmpFromPixels(img.getPixelsRef());  
    FreeImage_Save(fif, bmp, fname.c_str(), JPEG_QUALITYGOOD);  
    count++;  
  

getBmpFromPixels is from 006 version of OF . It is not beautiful but works.