Fixed potential overflow bug

Closes https://github.com/PistonDevelopers/rust-graphics/issues/510