Optimality of general lattice transformations with applications to the Bain strain in steel