How do universities (particularly medium sized ones) plan their master course schedule?
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.