Optimal control of the Landau-de Gennes model of nematic liquid crystals