Centralize resource deallocation for encmain.

- CppCheck was complaining about unreleased resources for FILE*. They weren't
  really because they get flushed and closed when program exits normally, but
  let's close them anyway.
Fix prototype of create_bitstream in bitstream.h
nal are now written to a bitstream, not a FILE*
Replace encoder->stream by stream
encoder->in.cur_pic --> cur_pic
added const in bitstream
some const in cabac.c
bitstream is a union, and is statically in encoder_control structure
Remove encoder_input width, height, height_in_lcu, and width_in_lcu
Remove g_bitdepth
Removed table generation from main code, moved it to tools.