Object result = makeAnOperationLocally(method, params,
paramClasses);
if (result instanceof BufferedImage) {
outputStream.writeObject("image");
BufferedImage image = BufferedImage.class.cast(result);
new PNGEncoder(outputStream, PNGEncoder.COLOR_MODE)
.encode(image, false);
//ImageIO.write(image, "png", outputStream);
} else {
outputStream.writeObject("OK");
outputStream.writeObject(result);