turn implicit integer conversions into static_casts to avoid warnings

When the option -Wconversion is given to GCC 4.8 it will warn about implicit, narrowing integer conversions. This kind of conversion is bad because you as a reader cannot see whether the narrowing was intended or happened by accident. A simple static_cast solves the problem by making the conversion explicit for the reader and for the compiler.
It is common to compile with -Wconversion and even -Werror, so this issue can really be a show-stopper for many organizations.
The behaviour of the code should not have changed, only the warnings are gone. The unit tests are still green on my machine (Ubuntu, AMD64, GCC 4.8).