def _md5_to_filename(md5):
    """
    Converts base64 encoded md5 to filename safe base64 encoding. Uneeded
    padding is removed and '+' and '/'  are replaced with safe alternatives.
    """
    return md5[:22].replace('+', '-').replace('/', '_')