added a safety check on some canvas image sizing