import base64
import zlib


def decode_b64_string(rle, height, width):
    """Converts a rle mask into a binary mask."""
    # Data
    rle = rle[2:-1]
    # Decompress
    base64_str = rle.encode("utf8")
    binary_str = base64.b64decode(base64_str)
    encoded_mask = zlib.decompress(binary_str)
    # To RLE
    encoded_mask = {'counts': encoded_mask, 'size': (height, width)}
    return(encoded_mask)