@jgoguen, @davidfor,
In the
forced_cleanup method of your container.py file, have you considered letting calibre do the hard work using it's standard Beautify function?
Code:
from calibre.ebooks.oeb.polish.pretty import pretty_all
pretty_all(container)
I don't know whether it will fix your current <br/> problem but in my own plugins I've generally found it a more reliable option than regex when trying to sort out things like self-closing tags. It might even fix the encoding stuff at the same time.