Updated to write directly png device/file.