def surface_to_image(surface):
    """Renders current buffer surface to IPython image"""
    from IPython.display import Image
    buf = BytesIO()
    surface.write_to_png(buf)
    data = buf.getvalue()
    buf.close()
    return Image(data=data)
Renders current buffer surface to IPython image