Adding in cross origin support and fixing up some code

This does some simple handing of cross origin images. It will still fails on some cross domain images, but will work with images that have the CORS enabled. 

Also fixed up some issues with the current code.

`ononerror` mispelling and send back uri as first parameter.