An octonionic construction of $E_8$ and the Lie algebra magic square