bug fixes for image loading