follow recommended usage pattern for writing images to file
(#590)