Numerical integration of Hamiltonian systems with external noise