Prevent from division by zero for 1 pixel images
Fix integer overflow in agg