Sorry for gravedigging but I found out the culprit. It was Archicrypt Ultimate Ramdisk. It has a feature that messes with the temp variables (to move temp files to a ramdisk etc) and I had it set up incorrectly. Need to tick "redirection of temporary files is done manually" in settings tab if you don't use that feature.