code: public static BufferedImage createColorModelCompatibleImage(BufferedImage image) {
          ColorModel cm = image.getColorModel();
          return new BufferedImage(cm,
              cm.createCompatibleWritableRaster(image.getWidth(),
                                                image.getHeight()),
              cm.isAlphaPremultiplied(), null);
      }
docs: <p>Returns a new <code>BufferedImage</code> using the same color model
  as the image passed as a parameter. The returned image is only compatible
  with the image passed as a parameter. This does not mean the returned
  image is compatible with the hardware.</p>
  
  @param image the reference image from which the color model of the new
  image is obtained
  @return a new <code>BufferedImage</code>, compatible with the color model
  of <code>image</code>