fix image_unit memory handling