Make sure filename is valid