Misc build fixes / Python 3 compatibility

Since I spent the afternoon trying to build s2e (now it compiles!), I think I should contribute a few fixes. These commits don't have any dependencies between them, so you can cherry pick them if you want.

Potential negative consequences:

- commits 351a813 and b1759f7 : likely none.
- commit 2c539bf slows the build (but make it work)
- commit dfe751c makes qemu script work with Python 3, at the cost of removing Python 2.5 compatibility.