Completed the support for two-pass encoding