Improved white-balance algorithm

Added white-balance saving for diagnostics.