Add test and fix image serialization.