Fix build issues in Ubuntu 12.04

Dear biomedia devs,

I had to apply a bunch of fixes to get the project to build on my Ubuntu 12.04 cluster. The changes are listed in this PR in separate commits. Feel free to apply some, all or none of them to the master branch.

Cheers,
Ghis