The Japanese were not planning to surrender unconditionally, which was the Allied demand. There were factions within the Japanese cabinet were seeking ways to negotiate a diplomatic end to the war — more of an agreement to stop fighting than a surrender, per se. But even those factions were not imagining unconditional surrender, which they saw as fundamentally antithetical to the survival of the Japanese imperial state.
The end of World War II has a lot of nuance to it. The Allied insistence on unconditional surrender, and the US refusal to clarify the status of the Emperor (which they knew was the major stumbling block), may have prolonged the war, for better or worse. It is not clear that the atomic bombs are what ended the war, either — the Soviet declaration of war against the Japanese, and their immediate invasion of Manchuria likely played as much, or even more, of a role in that. So it is not as simple as saying "the Japanese were planning to surrender" (they weren't) or that the bombs ended the war (it's unclear).
Even after the two atomic bombs, even after the invasion of Manchuria, the Japanese still only offered a conditional surrender (with the preservation of the Emperor being the condition), which was rejected by the US. After continued (conventional) bombing, and an attempted coup, the Emperor himself finally relented.
Hasegawa's Racing the Enemy covers this ground very carefully, and is recommended reading.