params.setDestinationType( new ImageTypeSpecifier( IndexColorModel.getRGBdefault(),
IndexColorModel.getRGBdefault().createCompatibleSampleModel( 16, 16 ) ) );
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream( outputStream );
imageWriter.setOutput( imageOutputStream );
imageWriter.write( null, new IIOImage( bufferedImage, null, null ), params );
imageOutputStream.close();
imageWriter.dispose();
}