The cmd-shift-3 and -4 actions just call the program /usr/bin/screencapture with the appropriate args.
You could probably do some clever stuff by (for example) renaming screencapture to something else and making a new perl script called screencapture. Then your perl script can interpret the args (like the output file), call the real screencapture, then post-process the output to convert the file or open it in Preview or whatever.
I actually wrote a command-line program to do basic screen captures to jpeg, and then replaced the original with my version. Unfortunately, my quick hack can't do most of the cool stuff that the real screencapture can do. (So I did the above perl hack to call the real screencapture when mine couldn't handle the arguments.)
Be creative and I'm sure you'll be able to come up with something that suits your needs.