This process is identical for Mac OS 10.10 Yosemite (replacing all instances of "Mavericks" with "Yosemite")
OS X 10.9 "Mavericks" is only available from Apple's App Store and at no cost.
Described below are procedures to produce installation media for OS X 10.9 "Mavericks" from the "Install OS X Mavericks.app" downloaded from the App Store. Unlike Mac OS 10.7, you can not simply restore the InstallESD.dmg image to a flash drive, you must use the createinstallmedia application.
/Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app
Occasionally, the booted installer will complain about being corrupt and will refuse to install. If this occurs, check your system time. If the time is not correct (can be caused by a dead clock battery) then the certificates will not match up.
Unfortunately, the Mac OS X installer (or recovery partition) does not include System Preferences making it slightly more difficult to fix the time. We can fix the time by using Terminal.
date {month}{day}{hour}{minute}{year}so December 5, 2014 at 7:30 AM would be 1205073014