added ComputeOutputLength function.