Generation of homogeneous granular packings: Contact dynamics method with coupling to an external pressure bath