Buying a foreclosed home can be a good way to score a deal while house hunting. Here's how a foreclosure sale works.