Fix bug with Gaussian and Retinex

Fix underflow and overflow issue with recursive gaussian filter, which
also causes serious bug in Retinex algorithm.