[solved] Cant read Pixels from FBO in ofAppNoWindow

Hi Friends, I was trying to read pixels from FBO and save it as image with an ofAppNoWindow (headless) instance. However I get a random image. Heres the code,

fbo.begin();
     ofClear( 255, 255, 255, 0 );
     ofEnableAlphaBlending();
     element.draw(); //element is my class
fbo.end();

and reading from fbo,

fbo.readToPixels(pixels);
pixels.setNumChannels(3);
vidRecorder.addFrame(pixels); //ofxVideoRecorder object

both “fbo” and “pixels” are OF_RGBA type.