Updated to write directly to png device/file.