Change encodeTreeBitstream() to use params class

This is a small change to make it easier to enhance the encodeTreeBitstream() function. Basically it just migrates over most of the parameters of this function into a struct/class.