code: public static void saveImage(BufferedImage image, OutputStream output) throws IOException
      {
          ImageIO.write(image, "png", output);
      }
docs: Save image to output stream.
  
  @param image The image to save.
  @param output The output stream.
  @throws IOException If error when saving image.