TVEnc: Bugfix and optimization