import base64


def _make_data_URI(data, output_format):
    """Convert the image with format output_format given as a byte array to a data URI."""
    media_type = None
    if output_format == 'png':
        media_type = 'image/png'
    elif output_format == 'svg' or format == 'svgz':
        media_type = 'image/svg+xml'
    else:
        raise Exception('Unknown image format "{0}"!'.format(output_format))
    return 'data:{0};base64,{1}'.format(media_type, str(base64.standard_b64encode(data), "UTF-8"))