add to gallery fix: write image data as binary