Wait until mask is loaded to prevent empty image bug. Add support for scaled images.