If you want to create an image to view instead of on the console,
RMagic/RScience may be convenient, but never forget how plain old easy
it is to make a PPM image :)
You just write it out as text!  This may be the easiest way to create
an image file from any language.

The header is 4 lines long, the data is written as r g b color values

Header:
First line is "P3"
Second line is a comment line that starts with "#" and goes however long
Third line contains two integers with a space between them, they
represent the size of the image
Fourth line is the maximum any color channel can be for any pixel.
For instance 7 will mean any pixel can have a red value 0-7, green
value of 0-7 and a blue value of 0-7.  If you use 255 you're getting 8
bits of color per channel, which is what were used to now days.

The data itself:
Everything now is just an integer, separated by a \n or a space.
Every triplet of integers represents a pixel, with each integer in the
triplet representing a different channel: Red, Green, Blue.
The triplets are written in order, with no particular formatting, no
indication that a new line is starting, and no indication that the
file or data has ended.  You just write them out, and it's up to the
viewer to read the header and know when the new line is, how many
integers to read, etc.
(There is a max length for any given line, and I don't remember what
it is, so be on the safe side and put in a \n after each pixel)

So this is a valid image file (1x3 pixels, one red one green one blue!)

P3
# comment line
1 3
255
255 0 0
0 255 0
0 0 255

Hope this helps some of you who want to write images, but don't want
to use a library (for some reason or another), or just don't want to
use something they don't understand.

--Kyle

PS:
http://netpbm.sourceforge.net has more info than I possibly can, and
probably describes it better, but longer.