Pseudofermion method for the exact description of fermionic environments: From single-molecule electronics to the Kondo resonance