Encodes/decodes view controller state