def METHOD_NAME(data, fn, scale=1.0, cmap='Greys'):
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    sizes = np.shape(data)
    height = float(sizes[0])
    width = float(sizes[1])
    fig = plt.figure()
    fig.set_size_inches(width/height, 1, forward=False)
    ax = plt.Axes(fig, [0., 0., 1., 1.])
    ax.set_axis_off()
    fig.add_axes(ax)
    if len(list(data.shape)) > 2:
        ax.imshow(data)
    else:
        ax.imshow(data, cmap=cmap)
    plt.savefig(fn, dpi=height*scale) 
    plt.close()