You could make a system call to use the 'import' command (you need to have ImageMagick installed for this) and just format the command:
import -window root name_of_image.png - the '-window root' bit means that it takes a screenshot of your whole desktop, not just a window. You can also make it save in different file formats by changing the extension, it'll do the rest.
TTFN,
Scrapz