set image.onload before image.src