ns = {'re': 'http://exslt.org/regular-expressions'}
img_url = doc.xpath("//a[re:test(@href, '\\.(?:png|jpg|jpeg)', 'i')]/@href",
    namespaces=ns, smart_strings=False)[0]
print(img_url)
Python, XPath: Find all links to images