Optimal control of integral equations