def METHOD_NAME(mask, width, height):
    def _to_image(arr):
        data = np.asarray(arr)
        if np.iscomplexobj(data):
            raise ValueError("Cannot convert a complex-valued array.")
        shape = list(data.shape)
        if len(shape) == 2:
            return _process_2d(data, shape)
        if len(shape) == 3 and shape[2] in (3, 4):
            return _process_3d(data, shape)
        raise ValueError("'arr' does not have a suitable array shape for any mode.")
    def _process_2d(data, shape):
        height, width = shape
        bytedata = _bytescale(data)
        image = Image.frombytes('L', (width, height), bytedata.tobytes())
        return image
    def _process_3d(data, shape):
        bytedata = _bytescale(data)
        height, width, channels = shape
        mode = 'RGB' if channels == 3 else 'RGBA'
        image = Image.frombytes(mode, (width, height), bytedata.tobytes())
        return image
    def _bytescale(data):
        if data.dtype == np.uint8:
            return data
        cmin = data.min()
        cmax = data.max()
        if cmin >= 0 and cmax <= 255 and data.dtype not in [np.float32, np.float16, float]:
            return data.astype(np.uint8)
        cscale = cmax - cmin
        if cscale == 0:
            cscale = 1
        scale = float(255) / cscale
        bytedata = (data - cmin) * scale
        return (bytedata.clip(0, 255) + 0.5).astype(np.uint8)
    image = _to_image(mask)
    image_new = image.resize((width, height), resample=0)
    return np.array(image_new)