You'll need to "buy" Mavericks on the MAS (it's free if you can locate it), or download it from there if already in your purchases tab. Once downloaded, follow the steps in
this article to build onto an 8 GB or larger USB flash drive (new, or one that doesn't have data you care about on it).
Once that's done, boot to the flash drive, format the internal drive in the disk utility on that drive then install the OS. Make sure you have a backup (NOT Time Machine as it may not restore a Yosemite backup to Mavericks) as you WILL lose any data on the internal drive during this process.