Save image by pillow module.
    Currently, pillow supports only uint8 to save.

    Args:
        path (str): output filename
        img (numpy.ndarray): Image array to save. Image shape is considered as (height, width, channel) by default.
        channel_first (bool):
            This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
            Default value is False, which means the img shape is considered as (height, width, channel)
        as_uint16 (bool):
            In this backend, this argument is always False because pillow dose not support uint16.
            If True, exception will be raised.
        auto_scale (bool) :
            Whether upscale pixel values or not.
            If you want to save float image, this argument must be True.
            In pillow backend, only float ([0, 1]) to uint8 ([0, 255]) is supported.

def imsave(path, img, channel_first=False, as_uint16=False, auto_scale=True):
    """
    Save image by pillow module.
    Currently, pillow supports only uint8 to save.

    Args:
        path (str): output filename
        img (numpy.ndarray): Image array to save. Image shape is considered as (height, width, channel) by default.
        channel_first (bool):
            This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
            Default value is False, which means the img shape is considered as (height, width, channel)
        as_uint16 (bool):
            In this backend, this argument is always False because pillow dose not support uint16.
            If True, exception will be raised.
        auto_scale (bool) :
            Whether upscale pixel values or not.
            If you want to save float image, this argument must be True.
            In pillow backend, only float ([0, 1]) to uint8 ([0, 255]) is supported.
    """
    img = _imsave_before(img, channel_first, auto_scale)

    if img.dtype == np.uint16 or as_uint16:
        raise ValueError("Pillow only supports uint8 image to save. Cast img to uint8."
                         "If you want to save image as uint16, install pypng or cv2 "
                         "and nnabla.utils.image_utils automatically change backend to use these module.")

    if auto_scale and img.dtype != np.uint8:
        img = (img * 255).astype(np.uint8)

    Image.fromarray(img).save(path)