Fix casting from unsigned to signed to get correct two's complement