Deutsche Bank posts a surprise third-quarter net loss, as heavy legal costs outweighed a rise in investment banking.