case python3
from PIL import Image
from IPython.display import HTML
from io import BytesIO
from base64 import b64encode
pil_im = Image.open('data/empire.jpg')
b = BytesIO()
pil_im.save(b, format='png')
HTML("<img src='data:image/png;base64,{0}'/>".format(b64encode(b.getvalue()).decode('utf-8')))