Optimal control of a chemotaxis system