fixed bug in image flipping for non 32 bit formats