code: def __FinalUrlValue(self, value, field):
          
          if isinstance(field, messages.BytesField) and value is not None:
              return base64.urlsafe_b64encode(value)
          elif isinstance(value, six.text_type):
              return value.encode('utf8')
          elif isinstance(value, six.binary_type):
              return value.decode('utf8')
          elif isinstance(value, datetime.datetime):
              return value.isoformat()
          return value
docs: Encode value for the URL, using field to skip encoding for bytes.