EDIT: added Yosemite (it's exactly the same as for Mavericks).
Creating an USB installer for Mac OSX Mavericks or Yosemite is a little different than previous releases. The InstallESD.dmg no longer contains the complete bootable installation files, so writing that image to an USB stick is no longer a valid option.
There's now a tool within the downloaded OSX Mavericks or OSX Yosemite app which creates a bootable volume with all the required files for installation from a media. You can then unleash the command on any mounted volume (including disk images), provided they are big enough. For USB or other flash media, you'll need at least 8GB or more.
For this to work, you need to download the OSX Mavericks or OSX Yosemite app from the AppStore on a Mac. Obviously you need to do this on a Mac that meets the upgrade requirements for Mavericks. Once downloaded, don't run the app (use Command + Q to exit).
You will also need any installation media usable to write the installation files. Any USB stick or flash media with size 8GB or larger will do.
Either write down the name of the volume on which the installation files have to be written, or erase the media and create a new empty volume with a specific name. Your best bet is to insert the media, go to Disk Utility, erase the media, providing a unique name. By default, this would be Untitled but I'm going with OSX_Installer to differiate from other media with that name.
Once you have your volume, it should be visible on the desktop or in Finder (see Devices). If not, you did something wrong at the first step.
Open up a Terminal and copy/paste the following command. Be sure to adjust the volume mount point to whatever name you've given your media. I used OSX_Installer as volume name.
sudo /Applications/Install OS X Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/OSX_Installer --applicationpath /Applications/Install OS X Mavericks.app --nointeraction
sudo /Applications/Install OS X Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/OSX_Installer --applicationpath /Applications/Install OS X Yosemite.app --nointeraction
Enter your password at the sudo prompt, then press Enter to start the process. If you do not have this password, you won't be able to perform the installation.
You'll get some output like so:
Erasing Disk: 0%... 10%... 20%... 100%... Copying installer files to disk... Copy complete. Making disk bootable... Copying boot files... Copy complete. Done.
It may take awhile before this is complete (usually around 20 minutes for USB 2.0 sticks). During that time, the terminal output may seem to hang, but this is not the case. Don't eject the media or interrupt the process.
When done, boot the Mac you wish to install Mavericks on with the Option key held down, then select the installation media to boot from, loading the Mavericks or Yosemite Installer. Follow the on-screen instructions to perform the installation.