cleaning up the open mode rather than truncating at the first 'e' char. Also, allow passing more than three flags through to fdopen().