Optimize image output when writing to files in ImageUtils routines.