Gran Tierra posts second-quarter loss