Ensure result dir exists before trying to write to it (#10918)

Change-Id: I7d01a80c10b8efd66b067023a7c56c6ba43e8265