import urllib.request, urllib.parse, urllib.error
file = cStringIO.StringIO(urllib.request.urlopen(
    'http://stackoverflow.com/a_nice_image.jpg').read())
pil_image = PIL.Image.open(file)
Convert image from PIL to openCV format