[all] Fix -Wconversion warnings
Imported issue: Initially reported by Jérémie Detrey in https://gforge.inria.fr/tracker/?group_id=2065&aid=16569
Lots of possibly harmful implicit type conversions (sign changes or size downcasts) occur throughout the code.
In order to avoid bugs due to such conversions, compiling with -Wconversion is good practice. At the moment, it generates about unique 2600 warnings (~1750 sign changes and ~850 size downcasts).
We should strive to get rid of all those warnings, adding explicit casts and range checks where necessary.