Preparation of anhydrous magnesium chloride by chlorinating magnesium compounds