added encode.cpp
makefile update, write histogram, cerr -> fprintf(stderr)
bin,val as hisogram output