# Buggy code
def add_logo(orig, dc, img, logo=None):
    """
    Add logos or other images to an image using the pydecorate function add_logo
    All the features in pydecorate are available

    See documentation of pydecorate
    """
    LOG.info("Add logo to image.")

    dc.add_logo(**logo)

    arr = da.from_array(np.array(img) / 255.0, chunks=CHUNK_SIZE)

    orig.data = xr.DataArray(
        arr,
        dims=["y", "x", "bands"],
        coords={
            "y": orig.data.coords["y"],
            "x": orig.data.coords["x"],
            "bands": list(img.mode),
        },
        attrs=orig.data.attrs,
    )


# Traceback (ValueError)
[INFO: 2018-10-08 23:46:08 : satpy.writers] Add coastlines and political borders to image.
[DEBUG: 2018-10-08 23:46:08 : satpy.writers] Automagically choose resolution f
[DEBUG: 2018-10-08 23:46:09 : trollimage.xrimage] Interval: left=<xarray.DataArray 'reshape-59920bd5c4344e209a876883f95f2db3' (bands: 1)>
array([0.])
Coordinates:
* bands     (bands) <U1 'L'
quantile  float64 0.005, right=<xarray.DataArray 'reshape-59920bd5c4344e209a876883f95f2db3' (bands: 1)>
array([67.693016])
Coordinates:
* bands     (bands) <U1 'L'
quantile  float64 0.995
Traceback (most recent call last):
File "msg4-ernst_single_channel.py", line 93, in <module>
global_scene.save_dataset(composite,'./MSG4.png', overlay={'coast_dir': '/home/cpeters/software/', 'width':1, 'color':(200, 200, 200)})
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/satpy-0+unknown-py3.6.egg/satpy/scene.py", line 1054, in save_dataset
**save_kwargs)
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/satpy-0+unknown-py3.6.egg/satpy/writers/__init__.py", line 611, in save_dataset
decorate=decorate, fill_value=fill_value)
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/satpy-0+unknown-py3.6.egg/satpy/writers/__init__.py", line 354, in get_enhanced_image
add_overlay(img, dataset.attrs['area'], fill_value=fill_value, **overlay)
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/satpy-0+unknown-py3.6.egg/satpy/writers/__init__.py", line 230, in add_overlay
resolution=resolution, width=width, level=level_coast)
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/pycoast/cw_agg.py", line 418, in add_coastlines
y_offset=y_offset)
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/pycoast/cw_base.py", line 598, in _add_feature
x_offset=x_offset, y_offset=y_offset, **kwargs)
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/pycoast/cw_base.py", line 510, in add_shapes
draw = self._get_canvas(image)
File "/home/cpeters/anaconda2/envs/pytroll/lib/python3.6/site-packages/pycoast/cw_agg.py", line 52, in _get_canvas
return aggdraw.Draw(image)
ValueError: bad mode

# Fixed code
def add_logo(orig, dc, img, logo=None):
    """Add logos or other images to an image using the pydecorate package.

    All the features of pydecorate's ``add_logo`` are available.
    See documentation of :doc:`pydecorate:index` for more info.

    """
    LOG.info("Add logo to image.")

    dc.add_logo(**logo)

    arr = da.from_array(np.array(img) / 255.0, chunks=CHUNK_SIZE)

    new_data = xr.DataArray(
        arr,
        dims=["y", "x", "bands"],
        coords={
            "y": orig.data.coords["y"],
            "x": orig.data.coords["x"],
            "bands": list(img.mode),
        },
        attrs=orig.data.attrs,
    )
    return XRImage(new_data)