// data.setFromTree("javax_imageio_jpeg_image_1.0", tree);
IIOImage image2 = new IIOImage(imageForSave, null, null);
writer.write(null, image2, iwp);
output.flush();
writer.dispose();
output.close();
} catch (IOException ex) {
Logger.getLogger(ImageProcessHandler.class.getName()).log(Level.SEVERE, null, ex);
}
}