move serialization methods into TaskMessage class