def get_dtype(max_value):
    """
    Calculate the appropriate dtype that will contain the max value

    Parameters
    ----------
    max_value : number
        max encoded value

    Returns
    -------
    numpy dtype string
    """

    if max_value <= 255:
        return "uint8"
    if max_value <= 65535:
        return "uint16"
    if max_value <= 4294967295:
        return "uint32"

    raise Exception("value is too large for uint32 / rgba")