Use Math.ceil instead of bitwise left shift.

Width or height might exceed 2147483648 pixels, which results in
negative numbers when using bitwise shift.
Also, 1px scaled with a factor of less than 1 should still be 1px.