I need to write an image to a .png with a 255-color indexed color model. I know usually do it like this:

BufferedImage img=new BufferedImage(width,height,BufferedImage.TYPE_BYTE_INDEXED,model);...