Costco's earnings beat Wall Street expectations as its same-store sales grew in the midst of a tough retail environment.