fix image upload (fixes #566)