add writeToBufferedImage method