fix image memory problem