code: def _SafeEncodeBytes(field, value):
      
      try:
          if field.repeated:
              result = [base64.urlsafe_b64encode(byte) for byte in value]
          else:
              result = base64.urlsafe_b64encode(value)
          complete = True
      except TypeError:
          result = value
          complete = False
      return CodecResult(value=result, complete=complete)
docs: Encode the bytes in value as urlsafe base64.