Fixes bug 907906
The logic is sound: if location=XXX is specified, use that.
If it's not specified, use sys.stdin to read image data. No need to
error when location=XXX is specified and stdin just happens to be a TTY.
(cherry picked from commit 1571cd8f83)
Change-Id: I057312becad59b3dd7a71f94d25ebd032e1a7b52