Amazon warns of loss in third quarter amid large-scale spending