How to preload images for canvas in JavaScript