Thank you for this post. I have been looking for this all day. You are a god among men!
Note that Flex has a JPEGEncoder class, which lets you encode the BitMapData data as JPEG data.
If you are not using Flex, you can still encode JPEG data. ActionScript code can access the JPEGEncoder class posted at the corelib project: