The following command should often produce a useful screenshot in X:
import -window root screenshot.jpeg
Import is part of the ImageMagick package. It can do many other formats as well; it will pick up what format you want from the extension. As usual you can find that, as well as other potentially useful info, in the manpage.