Iterator itr = ImageIO.getImageWritersByMIMEType(mimeType);
if (itr.hasNext()) {
ImageWriter w = (ImageWriter) itr.next();
w.setOutput(ImageIO.createImageOutputStream(outputStream));
w.write(convertToBufferedImage(image));
w.dispose();
} else {
throw XMLMarshalException.noEncoderForMimeType(mimeType);
}
return new EncodedData(outputStream.toByteArray(), mimeType);