Changed to use ImgeWriter.write(BufferedImage, OutputStream)