Fix implementation of Bresenham's line algorithm