We report a lattice QCD determination of the $pigamma to pipi$ transition amplitude for the $P$-wave, $I=1$ two-pion final state, as a function of the photon virtuality and $pipi$ invariant mass. The calculation was performed with $2+1$ flavors of clover fermions at a pion mass of approximately $320$ MeV, on a $32^3 times 96$ lattice with $Lapprox 3.6$ fm. We construct the necessary correlation functions using a combination of smeared forward, sequential and stochastic propagators, and determine the finite-volume matrix elements for all $pipi$ momenta up to $|vec{P}|= sqrt{3} frac{2pi}{L}$ and all associated irreducible representations. In the mapping of the finite-volume to infinite-volume matrix elements using the Lellouch-Luscher factor, we consider two different parametrizations of the $pipi$ scattering phase shift. We fit the $q^2$ and $s$ dependence of the infinite-volume transition amplitude in a model-independent way using series expansions, and compare multiple different truncations of this series. Through analytic continuation to the $rho$ resonance pole, we also determine the $pigamma to rho$ resonant transition form factor and the $rho$ meson photocoupling, and obtain $|G_{rhopigamma}| = 0.0802(32)(20)$.