Refactor code in ImageManager and LoadImageTask.