Bristol City won 3-1 at Middlesbrough - their first victory since September 18 - to end an 11-game winless run.