Counteracting dephasing in Molecular Nanomagnets by optimized qudit encodings