added encode/serialization functions for basic ints, bytes and index header. Added unit tests for encode/decode