P-representation techniques, which have been very successful in quantum optics and in other fields, are also useful for general bosonic quantum-dynamical many-body calculations such as Bose-Einstein condensation. We introduce a representation called the gauge P representation, which greatly widens the range of tractable problems. Our treatment results in an infinite set of possible time evolution equations, depending on arbitrary gauge functions that can be optimized for a given quantum system. In some cases, previous methods can give erroneous results, due to the usual assumption of vanishing boundary conditions being invalid for those particular systems. Solutions are given to this boundary-term problem for all the cases where it is known to occur: two-photon absorption and the single-mode laser. We also provide some brief guidelines on how to apply the stochastic gauge method to other systems in general, quantify the freedom of choice in the resulting equations, and make a comparison to related recent developments.