Implement arithmeticEncode and modify some define keyword and do documentation.