Probing gluon and heavy-quark nuclear PDFs with γ + Q production in pA collisions