The salt is here to prevent cost sharing by attackers. If two passwords are hashed with the same salt, then an attacker could hash a potential password using that salt value, and compare the output with the hashed versions of the two passwords; in other words, the attacker can attack the two hashed passwords for the cost of attacking one. This scales up: if there are 1000 hashed passwords, all with the same salt, then the attacker gets 999 of them "for free".
This kind of cost sharing can take several forms, one of them being precomputed tables (and one specific kind of table is called "rainbow table"). In all generality, cost sharing is an instance of parallelism (with the appropriate space-time warp).
You should strive to reuse salt values as rarely as possible; if possible, never. In your case, you would store the salt along with the encrypted file; and each file would have its own salt value (even if two files use the same password, each should have its own salt).
If each file has its own salt value, then you could do any of the following for the IV:
- Select a random IV and add it to the file header (along with the salt).
- Use PBKDF2 to generate the key and the IV in one go (e.g. ask for 256 bits of output, 128 for the key and 128 for the IV).
- Use a fixed IV.
The second and third option are safe only if you are really generating a new salt for each file, in a big enough space that collisions don't occur in practice. Otherwise, you may end up with IV reuse, which is a sin. Specifically, what is Really BadTM is using twice the same IV with the same key. If each file has its own key (because the key comes from processing the password with the salt and each file has its own salt) then a fixed IV is fine.
Anyway, if you need encryption then chances are that you need checked integrity as well, which calls for a MAC. Assembling encryption and a MAC properly is tricky. The proper way is to use an encryption mode that already does the job in a way that makes cryptographers happy. In practice, use
'aes-128-gcm': 128 bits are already good enough, and it will be slightly faster).
Note that the actual IV length for GCM is 12 bytes.