fix image uploading edge cases;