Add utility function for converting models to dicts

This converts ndb or db models to JSON-encodable dicts, useful for
building REST APIs.