used freeimage plugin to make sure output image is uint8