First download the installer app. (Install Mac OS X Lion.app, or Install OS X Mavericks.app, etc.)
Then right-click on the app to "Show Package Content".
Locate "InstallESD.dmg" under Contents/SharedSupport. Copy it to your home folder.
Insert the USB FlashDrive and Erase it, (MacOS Extended, GUID Partition Map.) Name it MyVolume.
Open Terminal and type:
sudo /usr/sbin/asr restore --source InstallESD.dmg --target /Volumes/MyVolume --erase
Enter your password.
Let the command run.
Validating target...done
Validating source...done
Erase contents of /dev/disk4s2 (/Volumes/MyVolume)? [ny]: y
Retrieving scan information...done
Validating sizes...done
Restoring ....10....20....30....40....50....60....70....80....90....100
Verifying ....10....20....30....40....50....60....70....80....90....100
Restored target device is /dev/disk4s2.
Remounting target volume...done
Restore completed successfully.
You now have a bootable USB Installer.