I sounds like you have already solved the problem. When you create a new image and call getGraphics(), the graphics object returned is directly related to the image and can be used to draw to the image.
If I understand the questions correctly, you code looks something like:
If so, you have done everything correctly a should see the desired output. Let me know if I have missed something.