Refactored to condense image processing code.
Uploading images from the web now supported.