import base64
import six


def _EncodeTaskPayload(payload):
  """Encodes a task payload.

  This function is compatible with Python 2/3.

  Args:
    payload: a payload string.
  Returns:
    a base64 encoded payload string.
  """
  s = base64.b64encode(six.ensure_binary(payload))
  return six.ensure_text(s)