Actually, the comments at the end of the line won't hurt anything. AppleScript uses two dashes to indicate a comment, so

set a to 1

is the same thing as

set a to 1 -- Which is, by the way, the loneliest number.

I'm not sure if changing the ".png" to ".jpg" will work, but try it. AppleScript is calling a shell script (UNIX stuff scares me) that activates the Finder's snapshot command. Snapshots are usually PDFs by default, but it can also do PNGs, and maybe even JPEGs.

(I've done more with AppleScript than any sane human being should, like building 20MB 3D files. Being able to refer to a "line," "paragraph," "word" or "character" is just so handy when you're slicing up text files.)