simplify writing image
add setFormat to fix tests on travis