Fix mask bug, add support for scaled images.

Hey,

after i added your script to my website i have a few problems:
1. The new data/base64 image was completely empty. The JS generated a full transparent png.
2. When the org. image is scaled, the "new" image has not the correct dimensions.

> Wait until mask is loaded to prevent empty image bug. Add support for scaled images.