Algebras with ternary law of composition and their realization by cubic matrices