def img_to_data_uri(img, format='jpg', jpeg_quality=75):
    """Given a numpy array `img`, return a `data:` URI suitable for use in 
  an HTML image tag."""
    from io import BytesIO
    out = BytesIO()
    import imageio
    kwargs = dict(format=format)
    if format == 'jpg':
        kwargs.update(quality=jpeg_quality)
    imageio.imwrite(out, img, **kwargs)
    from base64 import b64encode
    data = b64encode(out.getvalue()).decode('ascii')
    from six.moves.urllib import parse
    data_url = 'data:image/png;base64,{}'.format(parse.quote(data))
    return data_url
