Entanglement transformation at absorbing and amplifying four-port devices