The easiest way to take a JPEG and draw on it, and then save an image that is the combination of the two, would be to have a movieclip where the JPEG is already there, or you can add the JPEG with code. Once you have that you would create a sprite or movieclip to sit on top of that, and that's the object you would draw into. At the end you would be able to convert the movieclip that holds both the JPEG and your doodling into a single image.
Analysing the JPEG to recognise areas would be very tough. If you want a paint by numbers drawing tool you would manually create all of the areas you want to be colored in, and each one would be a movieclip with just that area as a white shape. You can then either use that shape as a mask layer and doodle under it, making sure the user draws within the lines, or you could tint the shape to get the whole area to fill in at once. That's the approach I've taken with my apps.
One thing to note, you can't just load a JPEG from anywhere in the world and expect to draw on top of it and to save a copy of the results, because of security issues. If you do want to load in JPEGs from outside they would need to be on your own server.