Graphics2D graphics2D = img.createGraphics();
graphics2D.setBackground(paintData.getBackground());
graphics2D.setColor(paintData.getDrawColor());
graphics2D.clearRect(0,0,paintData.getWidth(),paintData.getHeight());
graphics2D.drawLine(5,5,paintData.getWidth()-5,paintData.getHeight()-5);
graphics2D.drawChars(new String("RichFaces").toCharArray(),0,9,40,15);
graphics2D.drawChars(new String("mediaOutput").toCharArray(),0,11,5,45);
ImageIO.write(img,"jpeg",out);
}