Return a 504 on timeout

Makes it obvious to the client when something took too long vs
when it errored.
Simplify timeout handling
Merge pull request #4 from timshadel/gateway-timeout

Gateway timeout