Binary and Ternary Codes of Hadamard Matrices