createValidImage uses a canvas correctly instead of trying to convert an image
to a data URL.