fix some bugs for image management