There is some helper in the SDK that may help your with this:
https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/test/tmp-file.js#L54