title: JPEG File Encoding and writeFile in Node JS
body: <p>I'm using <code>http.request</code> to download JPEG file. I am then using <code>fs.writeFile</code> to try to write the JPEG file out to the hard drive.</p>
  
  <p>None of my JPEG files can be opened, they all show an error (but they do have a file size). I have tried all of the different encodings with <code>fs.writeFile</code>.</p>
  
  <p>What am I messing up in this process?</p>
  
  <p>Here's what the working one is showing when viewing it raw:
  <img src="https://i.stack.imgur.com/qIIEf.png" alt="enter image description here"></p>
  
  <p>And here is what the bad one using fs.writeFile is showing:
  <img src="https://i.stack.imgur.com/FG1Fx.png" alt="enter image description here"></p>