Nuclear photoproduction of charged pions near threshold