How do universities (particularly medium sized ones) plan their master course schedule? I'm a student at a university of around 20,000 students (using the semester system, just to be clear) and it's currently summer/fall registration planning time, a time for me which is more stressful than any of my classes, with all of the various requirements that must be met, especially since I must fit in gened, major, and honors courses in my schedules.

As hard/stressful as it is for me, it must be an absolute nightmare for the university. It's not a large enough school that they can just offer 20 slots of a specific course (this happens, but only for nearly universal courses like comp I), and the majority of courses required for my major are offered once per year, in one section only.

How on Earth do schools deal with the logistical nightmare that must be planning hundreds of courses while avoiding conflicts which would make it impossible to meet requirements on time and making sure enough slots for each course are open?
At my institution, this planning is done separately by each department, which reduces the number of courses from "hundreds" to "dozens".

In my department, it's done by hand, by the chair and a couple other experienced faculty members, with the aid of some spreadsheets.  They are familiar with the requirements of the degree programs offered within the department, and some of the most common conflicts with other departments.  (For example, calculus is taken by many first-year physics majors, so we try not to schedule it at the same time as the intro physics lab.)  

Over time, various courses have settled into "traditional" time slots which are known to work reasonably well together, so we use caution when deviating from tradition.

This does mean that students with more unusual programs (double majors, etc) may find conflicts between required courses which can be difficult or impossible to resolve.   These have to be handled case-by-case; in some cases the department may waive or modify requirements that can't reasonably be satisfied.