added dequantization to encoding loop