Newcastle United booked their place in the semi-finals of the Carabao Cup with a 3-1 win over Brentford at St James' Park.