'Converts a Task payload into UTF-8 and sets headers if necessary.
Args:
payload: The payload data to convert.
headers: Dictionary of headers.
Returns:
The payload as a non-unicode string.
Raises:
InvalidTaskError if the payload is not a string or unicode instance.'

@staticmethod
def __convert_payload(payload, headers):

    if isinstance(payload, unicode):
        headers.setdefault('content-type', 'text/plain;    charset=utf-8')
        payload = payload.encode('utf-8')
    elif (not isinstance(payload, str)):
        raise InvalidTaskError(('Task    payloads    must    be    strings;    invalid    payload:    %r' % payload))
    return payload
