Added explicit casts to allow for compilation under -pedantic

@arstrube found that I broke the build with -pedantic enabled due to a comparison between signed and unsigned values.  Added explicit casts to fixed.