import base64


def b64str_to_img_stream(src, urlsafe=False):
    """
    Decode a Base64 string of image to the image file's byte stream.
    :param src: The Base64 string you want to decode.
    :param urlsafe: Trigger using URL-Safe format. Must be consistent with what you generate with.
    :return: Decoded byte stream of image.
    """
    stream_base64 = src.encode('utf-8')

    if urlsafe:
        stream = base64.urlsafe_b64decode(stream_base64)
    else:
        stream = base64.standard_b64decode(stream_base64)

    return stream