Adding onImageLoaded event handler