ofPixels::setfromPixels strange output

I am trying to combine multiple live video camera feeds. for this i am using this particular code.

combinedVideo = (unsigned char*)malloc(Width * Height * cameraAmount * 3 * sizeof(unsigned char));  
if (bNewFrame){  
         memcpy(combinedVideo, vidGrabber_[0].getPixels(), Width * Height * 3);  
	 memcpy(combinedVideo + (Width * Height * 3), vidGrabber_[1].getPixels(), Width * Height * 3);  
pix.setFromPixels(combinedVideo, 320,240*2,3);  

this works fine till i am performing vertical stitching, but when i try horizontal stitching (pix.setFromPixels(combinedVideo,320*2,240,3) it gives a wierd output.
can anyone point me to what i may be doing wrong?