finished and tested encoding.cpp/h