What was the US hoping to avoid by dropping the atomic bombs?

The invasion of Mainland Japan, which was the only other alternative, and which would have been horrifically costly in lives - both American and Japanese.