Under extreme conditions, e.g. at high temperatures like in the early Universe, the usual magnetohydrodynamical (MHD) equations need to be extended. The origin of the modification is the asymmetry of the chemical potential of right- and left-handed fermions. To describe the evolution of a plasma, additional terms as well as new equations for the chiral chemical potential have to be included. We have implemented these extensions in the Pencil Code, which is a high-order finite-difference code developed for solving compressible MHD. We study laminar dynamos and find an exponential increase of the magnetic energy with the growth rate depending on the chemical potential. We further analyze the evolution of magnetic fields in the presence of turbulence. Potentially, chirality has interesting effects on the properties of magnetic fields in the early Universe and in particular on the evolution of magnetic helicity which is directly coupled to the chiral chemical potential.