Here's an example that show exactly how to do it... http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/

I also created a modified version of that...