Automorphism groups of K3 surfaces and hyperkähler manifolds