implement serialize interface.