write images in binary mode