Automatically create any non-existent directories before writing the buffer.