Hmmm.. You might want to try something like the following, in preprocess_html:
for a in soup.findAll('a'):
img = a.find('img')
if img is not None:
a.replaceWith(img)
else:
a.extract()
Haven't tried it, but I'm thinking that it should replace the relevant <a> tags with the straight embedded <img> tags, and delete all the other <a> tags. Give it a shot and let me know if it works....